#ifndef CLIPPY_H_
#define CLIPPY_H_
#include <X11/Xlib.h> 
#include <X11/Xatom.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include "Clipboard.h"
#include "XDisplay.h"

bool equal(std::string* s1, std::string* s2) ;


class Clippy {
	static map<Atom, void *>  registry;
	XDisplay * display_;
	
public:
	Clippy(XDisplay * display): display_(display) {}
	virtual ~Clippy(){};
	
	
	
	void mapWindow(Window window);
	
	
	Clipboard * getClipboard(Atom atom){
		XWindow *window = new XWindow(display_);
		//window->selectInputMask(StructureNotifyMask);
		//window->map();
		window->selectInputMask(StructureNotifyMask+ExposureMask);
		return new Clipboard(window, atom);
	}
	
	Clipboard * getClipboard(const string& name) {
		Atom atom = display_->getAtom(name);
		Clipboard * clip = (Clipboard *)registry[atom];
		if (clip == NULL) {
			clip = getClipboard(atom);
			registry[atom] = clip;
		}
		return clip;
		}
private:
	/* dont'allow coping */
	Clippy(const Clippy&);
	void operator=(const Clippy&);
};

#endif /*CLIPPY_H_*/
